<template>
    <view class="popup-dialog" v-if="showDialog">
        <view class="pop-item">
            <uni-list class="pop-list" :border="false">
                <uni-list-item style="display: table-cell" v-for="(item, index) in this.menuList"
                               clickable
                               @click="onClickPopMenu"
                               :to="item.toPage"
                               :link="item.toLink"
                               :showArrow=false>
                    <template v-slot:body>
                        <text class="slot-text">{{item.name}}</text>
                    </template>
                </uni-list-item>
            </uni-list>
        </view>
    </view>
</template>

<script>
import UniList from "../uni_modules/uni-list/components/uni-list/uni-list.vue";
import UniListItem from "../uni_modules/uni-list/components/uni-list-item/uni-list-item.vue";

export default{
    name: "popup-dialog",
    components: {UniListItem, UniList},
    props:{
        isShow:{
            type: Boolean,
            default: false
        },
        list:{
            type:Array,
            default: ()=>{
                return []
            }
        }
    },
    data(){
        return {
            showDialog:false,
            menuList:[],
            topPosition:0,
            rightPosition:0,
            leftPosition:0
        }
    },
    watch:{
        isShow:{
            immediate:true,
            handler:async function (newVal,oldVal){
                this.showDialog = newVal;
            }
        },
        list:{
            immediate:true,
            handler:async function (newVal,oldVal){
                this.menuList = newVal;
            }
        }
    },
    methods:{
        onClickPopMenu(e){
            this.showDialog = false
        },
    }
}
</script>

<style>

.popup-dialog {
    z-index: 999;
    top: 1%;
    right: 1%;
    position: absolute;
    width: 100px;
    display: table;
    background: #ffffff;
    border-radius: 5px;
    border: 1px solid rgba(168, 168, 168, 0.02);
    box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, .2);

    .pop-list {
        flex: 1;
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        margin: auto;
    }
}

.popup-dialog::before {
    position: absolute;
    bottom: 98%;
    left: 82%;
    content: '';
    width: 10px;
    height: 10px;
    background: #ffffff;
    transform: rotate(135deg);
    box-shadow: 1px -2px 5px 1px rgba(0, 0, 0, .2);
}

.popup-dialog::after {
    position: absolute;
    bottom: 90px;
    left: 70px;
    content: '';
    width: 20px;
    height: 10px;
    background: #ffffff;
}

.slot-text {
    margin-left: 2px;
    text-align: center;
    color: #a1a1a1;
}
</style>
